package com.javaee.web.servlet;
import java.io.IOException;
import java.util.List;

import com.javaee.ejb.entity.Employee;
import com.javaee.ejb.entity.Project;
import com.javaee.ejb.session.remote.EmployeeManagerRemote;
import com.javaee.ejb.session.remote.ProjectManagerRemote;
import com.javaee.web.HttpServletBase;
import com.javaee.web.SiteParameters;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class AdministrationServlet
 */
public class AdministrationServlet extends HttpServletBase {
	private static final long serialVersionUID = 1L;

	@EJB
	private ProjectManagerRemote projectManager;

	@EJB
	private EmployeeManagerRemote employeeManager;

	/**
	 * @see HttpServletBase#HttpServletBase()
	 */
	public AdministrationServlet() {
		super();
	}

	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		List<Project> projectList = projectManager
				.getListAdministrationConsole();
		request.setAttribute("projectList", projectList);

		List<Employee> employeeList = employeeManager.getListNotAdmin();
		request.setAttribute("employeeList", employeeList);

		loadJSP(SiteParameters.getPagePath("administration"), request, response);
	}

}
